package com.srcbox.file.fragment

import android.app.Activity
import android.content.Context
import android.graphics.Point
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import androidx.cardview.widget.CardView
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.alibaba.fastjson.JSON
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.srcbox.file.R
import com.srcbox.file.adapter.LocalFunList
import com.srcbox.file.util.EggIO
import com.srcbox.file.util.EggUtil

class LocalFilesGet() : Fragment() {
    private val context: Activity? = activity

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val v = inflater.inflate(R.layout.fragment_local_files_get, container, false)
        initView(v)
        return v
    }

    private fun initView(v: View) {
        val localFunLV = v.findViewById<RecyclerView>(R.id.localFunList)


        localFunLV.layoutManager = GridLayoutManager(context, 2)
        localFunLV.adapter = LocalFunList(
            activity!!,
            JSON.parseArray(EggIO().readFile(activity?.assets?.open("localFunList.json")!!)),
            v
        )
    }
}









//        val l = ArrayList<>()


/* bsb.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
       override fun onSlide(p0: View, p1: Float) {}
       override fun onStateChanged(p0: View, p1: Int) {}



         val radii = FloatArray(8)
        radii[0] = 120f
        radii[1] = 120f
        radii[2] = 120f
        radii[3] = 120f
        radii[4] = 0f
        radii[5] = 0f
        radii[6] = 0f
        radii[7] = 0f



   })*/

/*  val bottomSheet = v.findViewById<CardView>(R.id.design_bottom_sheet1)*/

/* EggUtil.setViewRadii(bottomSheet, "#ffffff", 2, "#ffffff", radii)
//        val localSrcList = bottomSheet.findViewById<RecyclerView>(R.id.local_src_list)

 val point = Point()
 context?.windowManager?.defaultDisplay?.getSize(point)
 val bsb = BottomSheetBehavior.from(bottomSheet)
 bsb.state = BottomSheetBehavior.STATE_HIDDEN
 bsb.peekHeight = point.y*/